stage.set_axis(100)
stage.create_grid_overlay(10, "grey")
stage.set_background("soccerfield")
ballx = -80
bally = random.randint(-100,100)
# sprite = codesters.Sprite("image", x, y)
ball = codesters.Sprite("soccerball", ballx, bally)
netx = 90
nety = random.randint(-100,100)
# sprite = codesters.Sprite("image", x, y)
net = codesters.Sprite("soccernet", netx, nety)
net.flip_right_left()
#sprite = codesters.Line(x-start, y-start, x-end, y-end, "color")
line = codesters.Line(ballx, bally, netx, nety, "blue")
slopeguess = float(line.ask("What is the slope of this line?"))
t = codesters.Teacher()
rises = t.find_text("rise")
try:
tval1 = rises[0][1].replace(" ", "")
except:
tval1 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == "rise=nety-bally" , "Great Job!")
t1.add_failure(tval1 == "DNE", "Did you drag out Delta Y and change delta_y to rise?")
t1.add_failure(tval1 == "rise=bally-nety", "You reversed bally and nety!")
t1.add_failure("-" not in tval1, "Did you drag out the Delta Y command?")
t1.add_failure("nety" not in tval1, "Did you change y2 to nety?")
t1.add_failure("bally" not in tval1, "Did you change y1 to bally?")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)